using System;

namespace HtmlParser
{
	/// <summary>
	/// Summary description for Utils.
	/// </summary>
	public class Utils
	{
		public static void PlaceString(char[] charArray,char[] inputArray,int insertAt)
		{
			for(int i = 0;i<inputArray.Length;i++)
			{
				charArray[i + insertAt] = inputArray[i];
			}
		}

		public static bool EndsWith(char[] stack,char[] test,int pos)
		{
			return StartsWith(stack,test,pos - test.Length);
		}

		public static bool StartsWith(char[] stack,char[] test,int pos)
		{
			if (pos < 0)
				return false;

			if (test.Length + pos > stack.Length)
				return false;


			for(int i = 0;i<test.Length;i++)
			{
				if (stack[i + pos] != test[i])
					return false;
			}

			return true;
		}

		public static void CleanUpCA(char[] stack)
		{
			bool endFound = false;
			for(int i = 0;i<stack.Length && !endFound;i++)
			{
				if (stack[i] == '\0')
					endFound = true;
				else
					stack[i] = '\0';
			}
		}
	}
}
